<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
<link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
<script src="${pageContext.request.contextPath}/js/jquery-1.9.1.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script type="text/javascript">
  $(document).ready(function(){
	  $("#serch").click(function(){
		  $("#info").empty();
		  var gid=$("#gid").val()
		    $.ajax({
        	type:'post',
        	url:'${pageContext.request.contextPath}/findgoodslist',
        	data:{"gid":gid},
        	dataType:'json',
        	success:function(data){
            if(data.msg=="对不起订单不存在"){
            	
            	$("#msg").text(data.msg);
            	$("#msg").show();
            	var t=setTimeout("$('#msg').hide()",1000);
            	
            }else{
            	 
            	var gid=data.gid;
        		var  gids=gid.split(",");
        		
        		var gname=data.gname;
        		var gnames=gname.split(",");
        		
        		var gnumber=data.gnumber;
        		var gnumbers=gnumber.split(",");
        		
        		$(gids).each(function(v,m){
        			$("#info").append("<tr id='id"+v+"'><td><input name='gid'style='width:30px' readonly='readonly' type='text' value='"+m+"'/></td></tr>")
        		});
        		
        		$(gnames).each(function(v,m){
        			$("#id"+v+"").append("<td><input name='gname' style='width:70px'  readonly='readonly' type='text' value='"+m+"'/></td>")
        		});
        		$(gnumbers).each(function(v,m){
        			$("#id"+v+"").append("<td><input name='gnumbers' style='width:30px' readonly='readonly' type='text' value='"+m+"'/></td>")
        		});
            }
        	
        		
        	}
        	
        })
	  })
	  $("#ruku").click(function(){
		  $("#msg1").empty();
		  $("#msg1").show();
	       var  info =  $("#rukuform").serializeArray();
		   var o ={};
		     $.each(info,function(index){
				  if(o[this['name']]){
				  o[this['name']] = o[this['name']] +","+this['value'];
				  }else{
				  o[this['name']] = this['value'];
				  }
				  });  
		     
		     $.ajax({
	            	type:'post',
	            	url:'${pageContext.request.contextPath}/ruku',
	            	data:{"ruku":JSON.stringify(o)},
	            	dataType:'text',
	            	success:function(data){
	            	  $("#msg1").text(data);
	            	  var t=setTimeout("$('#msg1').hide()",1000);
	            	
	            	}
	            	
		     
	  })
	 
	   
  })
  
  })


</script>
</head>
<body>
 <div class="container-fluid">
   <div class="row">
     <div class="col-md-12" >
     <br>
        <form  class="form-inline" role="form">
  
			  <div class="form-group has-success has-feedback">
			    <input id="gid" name="gid" type="text" class="form-control" placeholder="请输入订货订单编号"/>
			    <span class="glyphicon glyphicon-search form-control-feedback "></span>
			  </div>
			 <button id="serch" type="button" class="btn btn-success">查询</button><label id="msg"></label>
         </form>
      </div>
      
      <div class="row">
       <div class="col-md-2" >
      </div>
      
       <div class="col-md-6" >
       <br><br>
         <form id="rukuform">
           <table id="orderinfo" class="table table-bordered table-condensed">
           <tr><td>商品编号</td><td>商品名称</td><td>进货数量(件)</td></tr>
            <tbody id="info"></tbody>
            
           </table>
     <label id="msg1"></label><button id="ruku" style="margin-left:450px" type="button" class="btn btn-success">入库</button>
          </form>
       </div>
       
      <div class="col-md-4">
      </div>
      </div>
   </div>
 </div>
</body>
</html>